#include "recordhlomodel.h"
#include "database/dbtabrecordhlo.h"

RecordHLOModel::RecordHLOModel(QObject* parent):QSqlTableModel(parent)
{

}


QVariant RecordHLOModel::data(const QModelIndex &index, int role) const
{
    if(!index.isValid())
            return QVariant();
    QVariant value=QSqlTableModel::data(index,role);
    switch(role)
    {
        case Qt::TextAlignmentRole:
            return Qt::AlignCenter;
            break;
//        case Qt::FontRole:
//            return QFont("Ubantu Medium",20,20);
//            break;
        case Qt::DisplayRole:
            if(index.column()==DBTabRecordHLO::INDEX_CHKRESULT)
            {
                switch (value.toInt()) {
                case 0:
                    return "无";
                    break;
                case 1:
                    return "下限";
                    break;
                case 2:
                    return "合格";
                    break;
                case 3:
                    return "上限";
                    break;
                default:
                    break;
                }
            }
            else
            {
                return value;
            }
            break;
        default:
            return value;
            break;
    }
    return QVariant();
}
